package p7.code;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

public class HiddenIterator {

    private final Set<Integer> set=new HashSet<Integer>();

    public synchronized void add(Integer i){
        set.add(i);
    }
    public synchronized void remove(Integer i){
        set.remove(i);
    }
    public void addTenThings(){
        Random r=new Random();//新建一个产生随机数的对象
        for(int i=0;i<10;i++){
            add(r.nextInt());
        }
        System.out.println("DEBUG:added ten elememts to "+set);//隐藏了迭代器
    }

    public static void main(String[] args) {
        new HiddenIterator().addTenThings();
    }


}
